Page({
  data: {
    hidden: false, //加载
    outline: false, //有无网络
    noData: false,
    list: [],
    show: false,
    newsType: 1,
    currentPage: 1,
    countDownMinute: '',
    countDownSecond: '00',
  },

  onLoad(query) {

  },

  onShow() {
    var that = this;
    my.getNetworkType({
      success: (res) => {
        if (res.networkAvailable) {
          that.setData({
            outline: false,
          })
          // 获取token
          my.getStorage({
            key: 'token',
            success: function(res) {
              that.setData({
                token: res.data
              })
            },
            fail: function(res) {
              my.alert({ content: res.errorMessage });
            }
          })
          that.post()
        } else {
          that.setData({
            outline: true
          })
        }
      }
    })
  },
  post() {
    var that = this;
    my.request({ // 调用自己的服务端接口，让服务端进行后端的授权认证，并且种session，需要解决跨域问题
      url: 'https://www.tiantong369.com/crm/usercoupon', // 该url是自己的服务地址
      method: 'POST',
      data: req,
      headers: {
        // 'x-access-token': that.data.token
      },
      success: (res) => {
        if (res.data.address.status == 200) {
          var arr = [];
          console.log(res.data.address.data.Traces)
          if (res.data.address.data.Traces.length == 0) {
            that.setData({
              Reason: '暂无轨迹信息',
              noData: true
            })
          } else {
            for (var i = 0; i < res.data.address.data.Traces.length; i++) {
              arr.push(res.data.address.data.Traces[i])
            }
            that.setData({
              noData: false,
            })
          }
          that.setData({
            list: arr,
            kefuphone: res.data.kefuphone,
            hidden: false,
          })

        } else {
          my.showToast({
            content: '' + res.data.message + '',
          })
        }
      },
      fail: (res) => {
        console.log('/Wxpay_callback:', res)
      },
    });
  },
  onHide() {
    // 页面隐藏
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onReady: function() {

  },

  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
})
